<?php
header("Content-Type:application/json;charset=utf-8");
require("../init.php");
session_start();
@$uid = $_SESSION["uid"];
$sql = " SELECT uname From dk_user WHERE uid = '$uid'";
$result = mysqli_query($conn, $sql);
if(mysqli_error($conn)){
    echo mysqli_error($conn);
}
//echo $uid;
//抓取数据
$row = mysqli_fetch_row($result);
//取出数据
$uname = $row[0];
//var_dump($uname);
//输出数据
if($uname != null){
//    echo '{"code": 1, "msg": "抓取到数据"}';
//    echo json_encode(["uname" => $uname]);
    echo json_encode(["code" => 1, "msg" => "抓取到数据", "uname" => $uname]);
}else{
    echo '{"code": 0, "msg": "未抓取到数据"}';
}